import geoip2.database


def get_location(ip_address: str):
    reader = geoip2.database.Reader('./GeoLite2-City.mmdb')
    res = reader.city(ip_address)
    ret_data = {
        'Country': res.country.names['zh-CN'],
        'Province': res.subdivisions[0].names['zh-CN'],
        'City': res.city.names['zh-CN'],
    }
    return ret_data


get_location('XXX.XXX.XXX.XXX')	# 任意公网IP，其他网段IP可能会报错，需要做个异常处理